package cn.spikego.advicelite.client.core.module.impl.render

import cn.spikego.advicelite.client.AdviceLite
import cn.spikego.advicelite.client.core.event.impl.ClientInternalTickEvent
import cn.spikego.advicelite.client.core.module.Module
import cn.spikego.advicelite.client.core.module.ModuleCategory
import cn.spikego.advicelite.client.eventapi.EventTarget
import java.awt.event.KeyEvent

class ESPModule : Module(
    "ESP",
    KeyEvent.VK_O,
    "ESP",
    ModuleCategory.RENDER
    ) {

    override fun onEnable() {
        super.onEnable()
    }

    override fun onDisable() {
        super.onDisable()
        try {
            val players = AdviceLite.getMinecraftUtil()?.getAllPlayers()
            if (players == null) return
            for (obj in players) {
                AdviceLite.getMinecraftUtil()?.setSharedFlag(obj, 6, false)
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    @EventTarget
    fun tick(event: ClientInternalTickEvent) {
        try {
            val players = AdviceLite.getMinecraftUtil()?.getAllPlayers()
            if (players == null) return
            for (obj in players) {
                AdviceLite.getMinecraftUtil()?.setSharedFlag(obj, 6, true)
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }
}